package com.ccmusic.dao.impl;

import java.util.List;

import com.ccmusic.dao.ListMatchingDao;
import com.ccmusic.entity.ListMatching;
import com.ccmusic.entity.MusicType;

public class ListMatchingDaoImpl extends BaseDao implements ListMatchingDao {

	@Override
	public boolean addMatching(String lid, String mid) {
		String sql = "insert into listmatching values(?,?)";
		int n = this.execute(sql, lid, mid);
		return n > 0 ? true : false;
	}

	@Override
	public boolean delMatching(ListMatching lm) {
		String sql = "delete from listmatching where mid=?";
		int n = this.execute(sql, lm.getMid());
		return n > 0 ? true : false;
	}

	@Override
	public List<ListMatching> showMacthing(String lid) {
		String sql = "select * from listmatching where lid=?";
		List<ListMatching> list = (List<ListMatching>) this.select(sql, ListMatching.class, lid);
		return list;
	}

	@Override
	public List<MusicType> getMusicsFromList(String uid, String lid) {
		String sql = "select * from musictype where mid in (select mid from listmatching where lid=?)";
		List<MusicType> lsit = (List<MusicType>) this.select(sql, MusicType.class, lid);
		return lsit;
	}

}
